package org.itli.jnsocket.Mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.itli.jnsocket.Pojo.JnSysUser;

@Mapper
public interface UserMapper {

    //用户登录
    @Select("select user_name from jn_sys_user where user_name = #{user_name} and password = #{password}")
    String Login(String user_name,String password);

    //更新用户登录相关信息
    @Update("update jn_sys_user set login_ip = #{login_ip},login_time = NOW() where user_name = #{user_name}")
    int LoginAddIP(String user_name,String login_ip);

    @Insert("INSERT INTO jn_sys_user (" +
            "    dept_id, " +
            "    user_name, " +
            "    nick_name, " +
            "    user_type, " +
            "    email, " +
            "    phone, " +
            "    sex, " +
            "    avatar, " +
            "    password, " +
            "    salt, " +
            "    status, " +
            "    login_ip, " +
            "    login_time, " +
            "    remark, " +
            "    create_by, " +
            "    create_time, " +
            "    update_by, " +
            "    update_time, " +
            "    del_flag" +
            ") VALUES (" +
            "    NULL, " +
            "    #{user_name}, " +
            "    NULL, " +
            "    '00', " +
            "    NULL, " +
            "    NULL, " +
            "    NULL, " +
            "    NULL, " +
            "    #{password}, " +
            "    NULL, " +
            "    NULL, " +
            "    NULL, " +
            "    NULL, " +
            "    NULL, " +
            "    '用户注册', " +
            "    NOW(), " +
            "    '用户注册', " +
            "    NOW(), " +
            "    NULL" +
            ")")
    int Register(String user_name,String password);

    //获取个人数据
    @Select("select * from jn_sys_user where user_name = #{user_name}")
    JnSysUser MyInfo(String user_name);

}
